#ifndef H_EREP_MONITOR
#define H_EREP_MONITOR

#include <QtCore/QtCore>
#include <QtGui/QtGui>
#include <QtWebKit/QtWebKit>

namespace erep
{

class InfoItem : public QTableWidgetItem
{
public:
    InfoItem() : QTableWidgetItem() {}
    InfoItem( const QString& text ) : QTableWidgetItem(text) {}
    
    virtual bool operator<( const QTableWidgetItem& other ) const;
};

class Monitor : public QWidget
{
    Q_OBJECT
public:
    typedef QList<QTableWidgetItem*> InfoItemList;
    
    Monitor( QWidget* parent=0 );
    virtual ~Monitor();
    
    QTableWidget* getTable() { return _table; }
    bool updateOneData( const QString& id, const QStringList& info );
    
public slots:
    void updatePersonData( const QString& id, const QByteArray& );
    void updateCompanyData( const QString& id, const QByteArray& );
    
    void setTableItem( int row, int col, const QString& content );
    void setStateItem( int row, const QString& content, int state );
    void sortColumn( int col );
    
    void dispatchList();
    void updateList();
    void saveList();
    void searchInList();
    void showSelected();
    void removeSelected();
    
    void showOneData( QTableWidgetItem* item );
    void analyzeOneData( QTableWidgetItem* item );
    
protected:
    QLineEdit* _searchBox;
    QTableWidget* _table;
    
    Qt::SortOrder _sortOrder;
    int _lastSortedColumn;
};

}

#endif
